import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * Write a description of class Explosion here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class Explosion extends Actor
{
    /**
     * Act - do whatever the Explosion wants to do. This method is called whenever
     * the 'Act' or 'Run' button gets pressed in the environment.
     */
    private GreenfootImage [] explosion;
    private int delay =0;
    private int sprite=0;
    
    public Explosion()
    {
        explosion = new GreenfootImage[20];
        for(int i=1; i<=explosion.length; i++)
        {
            explosion[i-1] = new GreenfootImage("Explo2_"+i+".png");
            explosion[i-1].scale(63,126);
        }
       
        setImage(explosion[sprite]);
    }
    public void act() 
    {
        this.animacion();
        if(sprite == explosion.length-1 )
        {
        getWorld().removeObject(this);
       // Greenfoot.delay(50);
        
       }// Add your action code here.
    }    
    
    public void animacion()
    {
       
        if(delay==4)
        {
            delay=0;
            sprite++;
            setImage(explosion[sprite]);
        }
        else
        delay++;
    }
}
